package init

import (
	"fmt"
	"gitee.com/yang-tong-shang/home/config"
	"gitee.com/yang-tong-shang/home/mysql"
	"gitee.com/yang-tong-shang/home/redis"
)

var (
	NacosConfig  config.Nacos
	GlobalConfig config.ApiConfig
)

func init() {
	ConfigInit()
	NacosInit()
	MysqlInit()
	RedisInit()
}
func ConfigInit() {
	NacosConfig = config.ConfigInit("./dev.yaml")
}
func NacosInit() {
	GlobalConfig = config.NacosInit(NacosConfig.NameSpaceId, NacosConfig.IpAddr, NacosConfig.Port, NacosConfig.DataId, NacosConfig.Group)
}
func MysqlInit() {
	appconf := GlobalConfig.Mysql
	DB := mysql.MysqlInit(appconf.User, appconf.Password, appconf.Host, appconf.Port, appconf.Database)
	//mysql.DB.AutoMigrate()//迁移数据表
	fmt.Println(DB)
}
func RedisInit() {
	Rdb := redis.RedisInit(GlobalConfig.Redis.Addr, GlobalConfig.Redis.Password, GlobalConfig.Redis.DB)
	fmt.Println(Rdb)
}
